<?php
	
	//add by lin
	
	define('__ROOT__', dirname(dirname(__FILE__)));
	require_once(__ROOT__.'\models\Conn.php'); 
	require_once(__ROOT__.'\models\Emergency.php');
	//end add
	
class EmergencyController extends Controller{

	private $id;

	public function base(){

	}

	public function showList(){
		var_dump("aaa");
		die();
		// $e1 = new Event();		
		// $list = $e1->listAll();
		// $arg_item = array();
		// foreach( $list as $item )
		// {
			// array_push($arg_item,implode("/",$item));
		// }
		// $arg = implode(":",$arg_item);
		// header("Location:app/views/event.php?list=$arg");
	}
	
	public function editPage()
	{
		$id = $this->id;
		$m1 = new Member();
		$item = $m1->getById($id);
		$arg = implode(":",$item);
		header("Location:app/views/edit_member.php?item=$arg");
	}
	
	public function deleteItem()
	{
		var_dump('delete');
		$id = $this->id;
		
		$m1 = new Member();
		$m1->delete($id);
		
		$this->showMemberList();
	}
	
	public function addItemPage()
	{
		header("Location:app/views/add_member.php");
	}
	
	//没改
	public function addItem()
	{
		$new_item_area = $_POST['area'];
		$new_item_time = $_POST['time'];
		$new_item_indicator = $_POST['indicator'];
		$new_item_value = $_POST['value'];
		$new_item_p5 = $_POST['p5'];
		
		$item = array("area"=>$new_item_area,"time"=>$new_item_time,"indicator"=>$new_item_indicator,"value"=>$new_item_value,"p5"=>$new_item_p5);
		//add by lin
		$r1 = new Resources();
		$r1->insert($item);
		$this->showEconomyList();
	}
	
	public function setParams($params)
	{
		$this->id = $params[0];
	}
}
